import * as tfc from "@tensorflow/tfjs-converter";
import * as BlazeFaceModel from "@tensorflow-models/blazeface";
export async function loadMobileNet() {
  window.indexedDB.deleteDatabase("my-model");
  var graphModel = null;
  try {
    graphModel = await tfc.loadGraphModel("indexeddb://my-model");
    console.log("从缓存中加载模型");
  } catch (e) {
    graphModel = await tfc.loadGraphModel(
      "https://storage.googleapis.com/tfhub-tfjs-modules/tensorflow/tfjs-model/blazeface/1/default/1/model.json"
    );
    graphModel.save("indexeddb://my-model");
    console.log("从网络中加载模型");
  }
  graphModel.maxFaces = 1;
  return new BlazeFaceModel.load(graphModel);
}
